<?php
/**
 * The Items model class for abstracting operations to the Items Entity
 *
 */

class Status extends Zend_Db_Table
{
    protected $_name = 'status'; //The name of the entity
    protected $_primary = 'id'; //The primary id for this Table

    //Declare the relational links to other Database entities
    protected $_referenceMap    = array(
        'Items' => array(
            'columns'           => 'id',
            'refTableClass'     => 'Items',
            'refColumns'        => 'id'
        )
    );
	
	
	/**
	 * Prepare the row dates, by transforming them into Zend_Date objects.
	 */
	private function prepareRow(&$row)
	{
		$row->currentPrice = round($row->currentPrice, 2); // Round to a curreny price
	}
	
	public function getItemById($id)
	{
		$row = $this->fetchRow($this->select()->where('id = ?', $id));
		
		if($row)
		{
			$this->prepareRow($row);
		}
		return $row;
	}
	
	public function getByEbayId($ebayId)
	{
		$row = $this->fetchRow($this->select()->where('ebayId = ?', $ebayId));
		if($row)
		{
			$this->prepareRow($row);
		}
		return $row;
	}
}
